<?php
namespace org\kahikai\database\mysql;

use org\kahikai\database\GeneExpressionDao;

require_once dirname(__FILE__) . '/../GeneExpressionDao.php';
require_once dirname(__FILE__) . '/KahikaiMysql.php';
require_once dirname(__FILE__) . '/../../domain/GeneExpression.php';

use org\kahikai\database\GeneDao;
use org\kahikai\domain\Gene;

/**
 * 
 * @author ch4mp
 *
 */
class MysqlGeneExpressionDao extends KahikaiMysql implements GeneExpressionDao {
	
	/**
	 * 
	 * @param int $speciesId
	 * @return an array of all GeneExpressions by gene and development step for specified Species
	 */
	public function getBySpeciesId($speciesId) {
		$map = array();
		
		$result = KahikaiMysql::query("SELECT gene_id, step_id, is_exprimed FROM SPECIES_GENE_DEVELOPMENT_STEP WHERE species_id=$speciesId");
		while ($record = $result->fetch_assoc()) {
			if(!array_key_exists($record['gene_id'], $map)) {
				$map[$record['gene_id']] = array();
			}
			$map[$record['gene_id']][$record['step_id']] = $record['is_exprimed'];
		}
		$result->close();
		
		return $map;
	}
}
?>